*Replicate statistics in did_imputation_stylized_facts_jc_v8.do
* Ratio of same after-merger products to number of products of target before merger (i.e., how many of target's products continued after merger)
gen share_nsp_afterT = nsp_after/nprodT if nprod_before>0 & nprodT>0 & nprod_after>0
sum share_nsp_afterT

collapse (mean) nsp_before nsp_after nprod_before nprod_after nsp_afterN nprodT nprod_cont nprod_sp_cont vrdT_sp vrdT vrdA_sp_before vrdA_sp_after vrdA_cont_before vrdA_cont_after vrdT_cont (sum) vrdA_before vrdA_after, by(cvrnrA aar cvrnrT)
* Replace nsp_afterN = 0 below
foreach x in nsp_before nsp_after nprod_before nprod_after nprodT nprod_cont nprod_sp_cont vrdT_sp vrdT vrdA_sp_before vrdA_sp_after vrdA_cont_before vrdA_cont_after vrdT_cont vrdA_before vrdA_after {
	replace `x' = 0 if `x'==.
}

* Fact 2
* Ratio of same pre-merger products to unique number of products of acquirer + target before merger (i.e., overlap from combined's perspective)
gen share_nsp_before = nsp_before/(nprod_before + nprodT - nsp_before) if nprod_before>0 & nprodT>0
sum share_nsp_before
post stats ("Fact 2") ("") ("Overlap number") (r(N)) (r(mean)) (r(sd))

* Share of same pre-merger products combined value to combined total value (i.e., overlap from combined's perspective)
gen share_vrd_sp_before = (vrdA_sp_before+vrdT_sp)/(vrdA_before+vrdT) if vrdA_before>0 & vrdT>0
sum share_vrd_sp_before
post stats ("Fact 2") ("") ("Overlap value") (r(N)) (r(mean)) (r(sd))

*Even if acquirer no products, should count as 0 because discontinued
*gen share_nsp_afterT = nsp_after/nprodT if nprod_after>0 & nprodT>0
replace nsp_after = 0 if nsp_after==.
replace nsp_afterN = 0 if nsp_afterN==.

* Fact 3
* Ratio of same pre-merger continued products to number of same pre-merger products (i.e., how many of overlapping products are continued after merger)
gen share_nprod_sp_cont = nprod_sp_cont/nsp_before if nsp_before>0 & nprodT>0 & nprod_after>0
sum share_nprod_sp_cont
post stats ("Fact 3") ("Overlapping") ("Survival") (r(N)) (r(mean)) (r(sd))

*Excluding those that were produced by acquirer before as well
* Ratio of non-overlapping continued products to number of non-overlapping products of acquirer before merger (i.e., how many of acquirer's non-overlapping products continued after merger, "natural survival")
gen share_nprod_cont_beforeAN = (nprod_cont - nprod_sp_cont)/(nprod_before - nsp_before) if nprod_before>0 & nprodT>0 & nprod_after>0
sum share_nprod_cont_beforeAN
post stats ("Fact 3") ("Non-overlapping A") ("Survival") (r(N)) (r(mean)) (r(sd))

*Excluding those that were produced by acquirer before as well
* Ratio of same after-merger products to number of non-overlapping products of pre-merger target (i.e., how many of target's non-overlapping products continued after merger)
gen share_nsp_afterTN = nsp_afterN/(nprodT - nsp_before) if nprod_before>0 & nprodT>0 & nprod_after>0
sum share_nsp_afterTN
post stats ("Fact 3") ("Non-overlapping T") ("Survival") (r(N)) (r(mean)) (r(sd))